let product = { price: 5, quantity: 2 };

let proxiedproduct = new Proxy(product, {
  get(target, key, receiver) {
    console.log('get');
    // 添加get参数接收器-receiver, 并传递到反射调用中， 保证对象具有继承或函数使用时的正确
    return Reflect.get(target, key, receiver);
  },
  set(target, key, value, receiver) {
    console.log('set');
    return Reflect.set(target, key, value, receiver);
  }
});

console.log(proxiedproduct.price);

proxiedproduct.price = 8;

console.log(proxiedproduct.price);

// get
// 5
// set
// get
// 8
